package com.online.onlineshop.config;

import com.online.onlineshop.interceptors.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
@Configuration
public class FilterForLoginConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        HandlerInterceptor handlerInterceptor = new LoginInterceptor();
        //配值白名单
        /*
        * 暂时有问题，先全都允许
        *
        * */
        ArrayList<String> whiteList = new ArrayList<>();
//        whiteList.add("/bootstrap3/**");
//        whiteList.add("/css/**");
//        whiteList.add("/images/**");
//        whiteList.add("/js/**");
//        whiteList.add("/web/register.html");
//        whiteList.add("/web/login.html");
//        whiteList.add("/web/index.html");
//        whiteList.add("/web/product.html");
//        whiteList.add("/user/register");
//        whiteList.add("/user/login");
         whiteList.add("/**");

        //完成拦截器的注册
        registry.addInterceptor(handlerInterceptor)
                .excludePathPatterns(whiteList);



    }
}
